package com.example.weblending.domain.statistics;

import com.example.weblending.vo.AnalyzeColumn;
import com.example.weblending.vo.CsvInputColumn;

public class Dti extends StatisticsBase{

    @Override
    public void init() {
        this.field.add(new StatisticsField("小于5"));
        this.field.add(new StatisticsField("5 - 10"));
        this.field.add(new StatisticsField("10 -15"));
        this.field.add(new StatisticsField("15 - 20"));
        this.field.add(new StatisticsField("20 - 25"));
        this.field.add(new StatisticsField("25 - 30"));
        this.field.add(new StatisticsField("30 - 35"));
        this.field.add(new StatisticsField("35 - 40"));
        this.field.add(new StatisticsField("40 - 45"));
        this.field.add(new StatisticsField("45 - 50"));
        this.field.add(new StatisticsField("50+"));
        this.reverse=true;
    }

    @Override
    public void insert(AnalyzeColumn cleanColumn) {
        set(cleanColumn.getDti(),cleanColumn.getIs(),cleanColumn);
    }

    @Override
    public void set(float num, float percent, CsvInputColumn cleanColumn) {
        int index=0;
        if (num>50){
            this.add(11,percent);
            index=11;
        }
        else if (num>45){
            this.add(10,percent);
            index=10;
        }
        else if (num>40){
            this.add(9,percent);
            index=9;
        }
        else if (num>35){
            this.add(8,percent);
            index=8;
        }
        else if (num>30){
            this.add(7,percent);
            index=7;
        }
        else if (num>25){
            this.add(6,percent);
            index=6;
        }
        else if (num>20){
            this.add(5,percent);
            index=5;
        }
        else if (num>15){
            this.add(4,percent);
            index=4;
        }
        else if (num>10){
            this.add(3,percent);
            index=3;
        }
        else if (num>5){
            this.add(2,percent);
            index=2;
        }
        else {
            this.add(1,percent);
            index=1;
        }
        if(this.reverse){
            index = field.size()-index+1;
        }
        cleanColumn.setDti(index);
    }
}
